package cn.islys.demospringboot.controller;

import cn.islys.demospringboot.domain.User;
import cn.islys.demospringboot.mapper.UserMapper;
import cn.islys.demospringboot.service.Impl.UserServiceImpl;
import cn.islys.demospringboot.service.UserService;
import org.apache.coyote.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HelloController {
    @Autowired
    private UserServiceImpl userServiceImpl;

    @RequestMapping("/hello")
//    @ResponseBody
    public String hello(){
        System.out.println("hello");
        return "hello";
    }

    @RequestMapping(value = "/users",method = RequestMethod.GET)
    //    @ResponseBody
    public List<User> getUsers(){
        List<User> user = userServiceImpl.getUsers();
        return user;
    }

    @RequestMapping(value = "/users/{id}",method = RequestMethod.POST)
    public List<User> getUserById(@PathVariable("id") int id){
        List<User> user = userServiceImpl.getUserById(id);
        return user;
    }
}
